package com.xhwl.logistics.strategy.impl;

import com.xhwl.logistics.bo.VehicleCarRecordBO;
import com.xhwl.logistics.bo.VehicleCarRecordInParkingLotBO;
import com.xhwl.logistics.bo.VehicleCarRecordRateBO;
import com.xhwl.logistics.bo.VehicleCarportBO;
import com.xhwl.logistics.bo.cent.VehicleIntegratedConfigBO;
import com.xhwl.logistics.bo.input.QueryVehicleCarRecordInParkingLotBO;
import com.xhwl.logistics.bo.input.QueryVehicleCarportBO;
import com.xhwl.logistics.bo.manipulate.VehicleSyncBO;
import com.xhwl.logistics.enums.VehicleCardTypeEnum;
import com.xhwl.logistics.strategy.IVehicleParkingLotHandler;
import com.xhwl.logistics.util.AboutDateUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.scheduling.annotation.Async;

import java.util.Collections;
import java.util.Date;
import java.util.List;

@Slf4j
//@Service
public class VehicleParkingLotNothingHandlerImpl implements IVehicleParkingLotHandler {
    @Override
    public void sync(VehicleIntegratedConfigBO vehicleIntegratedConfigBO, VehicleSyncBO vehicleSyncBO) {
        log.info("nothing handler sync!");
        log.info("VehicleIntegratedConfigBO: " + vehicleIntegratedConfigBO);
    }

    @Override
    public VehicleCarportBO queryCarport(VehicleIntegratedConfigBO vehicleIntegratedConfigBO, QueryVehicleCarportBO queryVehicleCarportBO) {
        log.info("nothing handler query carport!");
        return new VehicleCarportBO(0, 0);
    }

    @Override
    public VehicleCarRecordInParkingLotBO queryCarRecordInParkingLot(VehicleIntegratedConfigBO vehicleIntegratedConfigBO, QueryVehicleCarRecordInParkingLotBO queryVehicleCarRecordInParkingLotBO) {
        log.info("nothing handler query carRecordInParkingLot!");
        //为了与前端对接接口的数据结构，因此VehicleParkingLotNothingHandlerImpl会生成一个假数据VehicleCarRecordInParkingLotBO
        VehicleCarRecordInParkingLotBO vehicleCarRecordInParkingLotBO = new VehicleCarRecordInParkingLotBO();

        vehicleCarRecordInParkingLotBO.setParkingLotName(queryVehicleCarRecordInParkingLotBO.getParkingLotName());

        VehicleCarRecordRateBO vehicleCarRecordRateBO = new VehicleCarRecordRateBO(0, 0, 0);

        VehicleCarRecordBO vehicleCarRecordBO = new VehicleCarRecordBO();
        vehicleCarRecordBO.setPlateNumber("测试车牌");
        vehicleCarRecordBO.setCardType(VehicleCardTypeEnum.TEMPORARILY.name());
        vehicleCarRecordBO.setEnterTime(AboutDateUtil.dateToString(new Date()));
        vehicleCarRecordBO.setStayTime(AboutDateUtil.durationString(0));
        List<VehicleCarRecordBO> vehicleCarRecordBOList = Collections.singletonList(vehicleCarRecordBO);

        vehicleCarRecordInParkingLotBO.setRate(vehicleCarRecordRateBO);
        vehicleCarRecordInParkingLotBO.setList(vehicleCarRecordBOList);
        return vehicleCarRecordInParkingLotBO;
    }

    @Async("threadPoolTaskExecutorForSchedule")
    @Override
    public void statisticsToBi(VehicleIntegratedConfigBO vehicleIntegratedConfigBO) {
        log.info("nothing handler statistics to bi!");
    }

}
